home *** CD-ROM | disk | FTP | other *** search
- /*****
- *
- * FILE: CMacLockApp.c
- * Programmer: Mark Bykerk Kauffman
- * Date: 1/91
- * Purpose:
- * Application methods for CMacLockApp.
- *
- * PARENTCLASS = CStarterApp
- *
- *****/
-
- #include "Commands.h" /* So cmdOpen and cmdAbout work inDoCommand.*/
- #include "MacLockCmds.h" /* This applications commands for DoCommand */
- #include "CMacLockApp.h"
- #include "CMacLockDoc.h"
- #include <CFWDesktop.h> /* Floating Window Desktop. */
- #include "CBartender.h"
- #include "CAboutMacLock.h"
- #include "CPassword.h"
-
- /* Global Variables for objects of this class. */
- extern CBartender *gBartender;
- extern CDesktop *gDesktop; /* The visible Desktop */
- extern CBureaucrat *gGopher; /* First in line to get commands*/
- CPassword *gThePassword;
-
- /* METHOD IMPLEMENTATIONS */
-
- /*****
- * IMacLockApp
- *
- * Initialize the application. Create an object, gThePassword, which
- * is global to the application and initialize it. Call the parent class
- * initialization method.
- *
- *****/
-
- void CMacLockApp::IMacLockApp(void)
- {
- gThePassword = new(CPassword);
- gThePassword->IPassword();
- CStarterApp::IStarterApp();
- }
-
- /*****
- * StartUpAction
- *
- * Start the application by asking for money.
- *
- *****/
-
- void CMacLockApp::StartUpAction(
- short numPreloads)
- {
- gGopher->DoCommand(cmdAbout);
- inherited::StartUpAction(numPreloads);
- }
-
-
- /*****
- * MakeDesktop
- *
- * Use the Desktop subclass which supports floating windows.
- * This was absolutly necessary to make the AboutMacLock work
- * properly. Without floating windows, the lock window was deselected
- * every time the AboutMacLock was called up.
- *
- *****/
-
- void CMacLockApp::MakeDesktop()
- {
- gDesktop = new(CFWDesktop);
- ((CFWDesktop*)gDesktop)->IFWDesktop(this);
- }
-
- /*****
- * UpdateMenus
- *
- * Menu management.
- *
- *****/
-
- void CMacLockApp::UpdateMenus()
- {
- inherited::UpdateMenus();
- gBartender->EnableCmd(cmdPassword);
- }
-
-
- /*****
- * DoCommand
- *
- * Commands 1-1023 are reserved. cmdPassword is defined in MacLockCmds.h,
- * cmdOpen and cmdAbout are defined in Commands.h. The inherited method
- * should always be called as the default of your switch statement so that
- * all standard commands that you don't handle will be taken care of.
- *
- *****/
- void CMacLockApp::DoCommand(long theCommand)
-
- {
- int numberofitems;
- CAboutMacLock *theAboutMacLock;
- CWindow *oldWindow;
-
- switch (theCommand) {
-
- /* These are the commands that MacLock responds to. */
-
- case cmdOpen:
- /* Override the inherited response to cmdOpen. Check
- how many directors the application has by sending a
- GetNumItems message to itsDirectors. If there are
- two, then the application already has a MacLock window
- on the screen and we don't want to display another.
- Remove the if statement and you will get another
- MacLock window every time you do an Open from the menu
- or press command-O.*/
- numberofitems = itsDirectors->GetNumItems();
- if (numberofitems < 2)
- CreateDocument();
- break;
-
- case cmdPassword:
- gThePassword->ChangePassword();
- break;
-
- case cmdAbout:
- theAboutMacLock = new(CAboutMacLock);
- theAboutMacLock->IAboutMacLock(this);
- theAboutMacLock->Dispose();
- FlushEvents(mDownMask+mUpMask+keyDownMask+keyUpMask
- +autoKeyMask, 0);
- break;
-
- /* Call the inherited DoCommand here.*/
- default: inherited::DoCommand(theCommand);
- break;
- }
- }
-
- /*****
- * CreateDocument
- *
- * Create the unique MacLock Document. Send it a newFile message so that
- * it opens a new MacLock window.
- *
- *****/
-
- void CMacLockApp::CreateDocument()
-
- {
- CMacLockDoc *theDocument;
-
- theDocument = new(CMacLockDoc);
- theDocument->IMacLockDoc(this, TRUE);
- theDocument->NewFile();
- }
-
- /*****
- * OpenDocument
- *
- * The user chose Open… from the File menu. Create a new Maclock document
- * (if one hasn't already been created).
- *
- *****/
-
- void CMacLockApp::OpenDocument(SFReply *macSFReply)
-
- {
- CMacLockDoc *theDocument;
-
- theDocument = new(CMacLockDoc);
-
- /* Send your document an initialization
- message. The first argument is the
- supervisor (the application). The second
- argument is TRUE if the document is printable.*/
-
- theDocument->IMacLockDoc(this, TRUE);
-
- /* Send the document an OpenFile() message.
- The document will open a window, open
- the file specified in the macSFReply record,
- and display it in its window.*/
-
- theDocument->OpenFile(macSFReply);
- }